package com.xxgc.eow.service.impl;

import com.github.pagehelper.PageHelper;
import com.xxgc.eow.entity.Address;
import com.xxgc.eow.mapper.AddressMapper;
import com.xxgc.eow.service.IAddressService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 企业地址表 服务实现类
 * </p>
 *
 * @author Mr.Abel
 * @since 2023-05-21
 */
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements IAddressService {

    @Resource
    private AddressMapper addressMapper;

    @Override
    public List<Address> getAllByCompanyId(int companyId) {
        return addressMapper.selectAllByCompanyId(companyId);
    }

    @Override
    public int delByCompanyId(Address address) {
        return addressMapper.delByCompanyIdInt(address);
    }

    @Override
    public int delByAddressName(Address address) {
        return addressMapper.delByAddressName(address);
    }


    @Override
    public int updatByOldName(Address address, String oldName) {
        return addressMapper.updateByOldAddressName(address, oldName);
    }

    @Override
    public int addAddress(Address address) {
        return addressMapper.insert(address);
    }

    @Override
    public List<Address> getAllByKeyWord(int pageNum, int pageSize, String KeyWord) {
        PageHelper.startPage(pageNum,pageSize);
        return addressMapper.selectByKeyWord(KeyWord);
    }

    @Override
    public List<Address> getAllPage(String keyWord) {
        return addressMapper.selectByKeyWord(keyWord);
    }
}
